package com.hcf.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hcf.project.common.convention.result.Result;
import com.hcf.project.common.convention.result.ResultTool;
import com.hcf.project.dto.req.RecycleBinPageReqDTO;
import com.hcf.project.dto.req.RecycleBinRecoverReqDTO;
import com.hcf.project.dto.req.RecycleBinRemoveReqDTO;
import com.hcf.project.dto.req.RecycleBinSaveReqDto;
import com.hcf.project.dto.resp.ShortLinkPageRespDTO;
import com.hcf.project.service.RecycleBinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 回收站管理控制器
 */
@RestController
@RequestMapping("/api/shortLink/v1/recycle-bin")
public class RecycleBinController {

    @Autowired
    private RecycleBinService recycleBinService;

    @RequestMapping("/save")
    public Result<Void> saveRecycleBin(@RequestBody RecycleBinSaveReqDto requestParam){
        return recycleBinService.saveRecycleBin(requestParam);
    }


    @RequestMapping("/page")
    public Result<IPage<ShortLinkPageRespDTO>> pageRecycleBin(@RequestBody RecycleBinPageReqDTO requestParam){
        return ResultTool.success(recycleBinService.pageShortLink(requestParam));
    }


    /**
     * 回复短链接
     * @param requestParam
     * @return
     */
    @RequestMapping("/recover")
    public Result<Void> recoverShortLink(@RequestBody RecycleBinRecoverReqDTO requestParam) {
        recycleBinService.recoverShortLink(requestParam);
        return ResultTool.success();
    }


    /**
     * 删除短链接
     * @param requestParam
     * @return
     */
    @RequestMapping("/remove")
    public Result<Void> removeShortLink(@RequestBody RecycleBinRemoveReqDTO requestParam) {
        recycleBinService.removeShortLink(requestParam);
        return ResultTool.success();
    }

}
